<?php
	require_once("../functions.php");
	if(!isLoggedIn()){
		header("location:index.php?message=".urlencode("Please login first."));
		die();
	}
	
	if(!isset($_POST["data"])){
		echo "No data";
		die();
	}
	
	echo "<h3 class='center'>JSON from Client</h3>";
	echo "<pre>".$_POST["data"]."</pre>";
	$decoded = json_decode($_POST["data"], true);
	
	switch(json_last_error()){
		case JSON_ERROR_DEPTH:
			echo '<br />PHP JSON decoding error : Maximum stack depth exceeded.';
		break;
		case JSON_ERROR_CTRL_CHAR:
			echo '<br />PHP JSON decoding error : Unexpected control character found.';
		break;
		case JSON_ERROR_SYNTAX:
			echo '<br />PHP JSON decoding error : Syntax error, malformed JSON.';
		break;
		case JSON_ERROR_NONE:
			echo '<br />PHP JSON decoding error : No errors.';
		break;
	}
?>